using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

namespace LabMS.Web.Application
{
    public partial class EquipList : Base.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataBinds();
        }

        protected void DataBinds() 
        {
            LabMS.BLL.Dictionary Dic = new LabMS.BLL.Dictionary();
            List<LabMS.Model.Dictionary> ls = new List<LabMS.Model.Dictionary>();
            ls = Dic.GetModelList(CombineStr());
            Gv_Equip.DataSource = ls;
            Gv_Equip.DataBind();

        }

        protected string CombineStr() 
        {
            string strWhere = " DClass ='EquipType'";
            if (tb_KeyWord.Text != "")
            {
                switch (ddl_SearchType.SelectedValue) 
                {
                    case "0":
                        strWhere += " and  Name like '%" + tb_KeyWord.Text.Trim() + "%'";
                        break;
                    case "1":
                        strWhere += " and  Code like '%" + tb_KeyWord.Text.Trim() + "%'";
                        break;
                }
            }
            return strWhere;
        }

        protected void Gv_Equip_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            Gv_Equip.PageIndex = e.NewPageIndex;
            DataBinds();
        }

        protected void Gv_Equip_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow) 
            {
                int Code=e.Row.RowIndex+1;
                e.Row.Cells[0].Text = Code.ToString();
                e.Row.Attributes.Add("OnDblClick", "DbClickEvent('" + e.Row.Cells[1].Text + "','" + e.Row.Cells[2].Text + "')");
                e.Row.Attributes["style"] = "Cursor:pointer";
            }
        }
    }
}
